package routefinder.renderer;

import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Map;
import routefinder.City;

/**
 * Renders plain text to the output stream.
 *
 * @author luky
 */
public class DefaultRenderer implements IRenderer {

    /**
     * @see routefinder.renderer.IRenderer
     */
    public void render(Map<String, Object> parameters, OutputStream output) {
        int shortestLength = (Integer) parameters.get("shortestLength");
        Map<City, Integer> routes = (Map<City, Integer>) parameters.get("routes");
        City origin = (City) parameters.get("origin");
        City destination = (City) parameters.get("destination");
        Integer numberOfTrips = (Integer) parameters.get("numberOfTrips");
        Integer tripsWithStrictNumberofStops = (Integer) parameters.get("tripsWithStrictNumberofStops");

        PrintStream printStream = new PrintStream(output);
        printStream.println("Shortest length between: " + origin + " and " + destination + ": " + shortestLength);

        printStream.println("Shortest path from origin... ");
        for (Map.Entry<City, Integer> entry : routes.entrySet()) {
            City key = entry.getKey();
            Integer value = entry.getValue();
            printStream.println("To: " + key + " = " + value);
        }
        printStream.println("Reachable destinations: " + routes.size());
        
        printStream.println("Possible trips: " + numberOfTrips);

        printStream.println("tripsWithStrictNumberofStops: " + tripsWithStrictNumberofStops);

        printStream.println("This is the end, my only friend, the eeend. :-)");

    }
}
